﻿Imports System.Collections.Specialized
Imports System.IO
Imports System.Globalization
Imports Microsoft.TeamFoundation.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client
Imports System.Collections.ObjectModel
Imports System

Namespace Controlers


    Public Class ControlerFactory(Of TView As {UIElement, IView})

        Private Shared m_MasterControler As ControlerFactory(Of TView)

        Private Sub New()

        End Sub

        Public Shared ReadOnly Property Instance() As ControlerFactory(Of TView)
            Get
                If m_MasterControler Is Nothing Then
                    m_MasterControler = New ControlerFactory(Of TView)
                End If
                Return m_MasterControler
            End Get
        End Property

        Private m_Controlers As New List(Of ControlerBase(Of TView))

        Public Sub AddControler(ByVal controler As ControlerBase(Of TView))
            controler.Factory = Me
            m_Controlers.Add(controler)
        End Sub

        Public Function GetControler(Of TControler As ControlerBase(Of TView))() As TControler
            Return m_Controlers.Find(Function(c) c.GetType Is GetType(TControler))
        End Function

    End Class

End Namespace